<template>
  <el-button @click="submit" :size="size" :type="type" v-bind="$attrs" v-on="$listeners"><slot></slot></el-button>
</template>

<script>
export default {
  data() {
    return {
    }
  },
  props: {
    flow_code: { type: String, default: null },
    data_id: { type: String, default: null },
    after_del: { type: Function, default: null },

    size: { type: String, default: 'small' },
    type: { type: String, default: 'text' },
  },
  created() {},
  mounted() {
  },
  methods: {
    submit(){
      this.$confirm('此操作将删除该数据，是否继续？','提示',
          { confirmButtonText:'确定',cancelButtonText:'取消',type:"warning"}
      ).then(()=>{
        this.goSubmit();
      });
    },
    async goSubmit(){
      let result = await elm.post('/system/login/flow/FlowsecFormItem_Delete', { 'id': this.data_id,'flow_code':this.flow_code });
      if(result){
        this.$message({ type: 'success', message: '数据已删除' });
        if(this.after_del!=null){ this.after_del(); }
      }
      else { this.$message.error('删除失败，请稍后再试'); }
    },

    em: function (s) {
      if (s == null || s == '') { return true; }
      else { return false; }
    },
  }
}
</script>